#!/bin/bash

maestro_dir="/home/tom/siweather/maestro"

connected=`$maestro_dir/./UscCmd --list 2>&1 | grep Maestro | awk '{ print $1}'`
if [ $connected -lt 1 ]; then echo "No Maestro servo controller found!"; exit 1; fi

echo "Starting at "`date`" ..."

cam_power_on
if [ $? -ne 0 ]; then exit 1; fi

gphoto2 --set-config capture=on
gphoto2 --set-config canonimgsize="medium 2"
gphoto2 --set-config capturetarget=0

# angles=( 25 70 115 160 205 250 295 340 )
angles=( 10 30 50 70 90 110 130 150 170 190 210 230 250 270 290 310 330 350 )

num_angles=${#angles[*]}

for i in {0..17} # MUST MAKE THIS 0..<number_of_pictures - 1> !!!
do
	echo "loop number "$i
	
	turn_servo ${angles[i]}
	sleep 1

	gphoto2 --capture-image-and-download --force-overwrite --filename /home/tom/web/pics/test/angle_"${angles[i]}".jpg
	convert /home/tom/web/pics/test/angle_"${angles[i]}".jpg -flip -flop /home/tom/web/pics/test/angle_"${angles[i]}".jpg
	convert /home/tom/web/pics/test/angle_"${angles[i]}".jpg -scale 640x480 /home/tom/web/pics/test/angle_"${angles[i]}".jpg
done

gphoto2 --set-config capture=off
sleep 1

# /home/tom/panorama/panorama im*.jpg
# rm *jpg.key* im*.jpg

cam_power_off



